/******************************************************************************
** File			:	SLRole.sql	 	
** Name			: 	SLRole
** Description	:	This script creates role and grants permission on  
**					tables and stored procedures used by  ServiceLogicUser
** Author		:	Anil Kasalanati	
** Date			: 	23-May-2007
*******************************************************************************
** Change History
*******************************************************************************

*******************************************************************************/
USE ServiceLogicDB

--CreateRole UISyncAsyncRole

	IF NOT EXISTS
		(
			SELECT UID
			FROM 	dbo.sysusers 
			WHERE 	NAME = N'SLRole'
		)

	EXEC sp_addrole N'UISyncAsyncRole'
GO
	
--grant permission to user on Tables
		
	GRANT  SELECT   ON [dbo].[StateCorrelation] 				TO [SLRole]
	GRANT  SELECT   ON [dbo].[DynamicMaps] 					TO [SLRole]
	GRANT  SELECT   ON [dbo].[ServiceMaps] 		TO [SLRole]
	

--grant permission to user on stroed procedure

	GRANT  EXECUTE  ON [dbo].[ps_d_Mid]			TO [SLRole]
	GRANT  EXECUTE  ON [dbo].[ps_i_DynamicMaps]			TO [SLRole]
	GRANT  EXECUTE  ON [dbo].[ps_i_InsertPayload]					TO [SLRole]
	GRANT  EXECUTE  ON [dbo].[ps_i_ServiceMaps]				TO [SLRole]
	GRANT  EXECUTE  ON [dbo].[ps_s_GetDynamicMap]			TO [SLRole]
	GRANT  EXECUTE  ON [dbo].[ps_s_GetIOMap]			TO [SLRole]
	GRANT  EXECUTE  ON [dbo].[ps_s_GetMid]			TO [USLRole]
	GRANT  EXECUTE  ON [dbo].[ps_u_UpdateMid]			TO [SLRole]
